package org.java.vm.command;

import java.util.ArrayList;
import java.util.List;

public class Lt implements ArithmeticCommand {
    private final ArithmeticHandler arithmeticHandler;
    private int label = 0;

    public Lt(ArithmeticHandler arithmeticHandler) {
        this.arithmeticHandler = arithmeticHandler;
    }

    @Override
    public List<String> calculate() {
        label++;
        List<String> commands = new ArrayList<>();
        commands.add("D=M-D");

        commands.add("@LT_" + label);
        commands.add("D;JLT");
        commands.add("D=0");
        commands.add("@LT_" + label + "_END");
        commands.add("0;JMP");
        commands.add("(LT_" + label + ")");
        commands.add("D=-1");
        commands.add("(LT_" + label + "_END)");
        return arithmeticHandler.operateTwoDigit(commands);
    }

    @Override
    public boolean canCalculate(String command) {
        return command.equalsIgnoreCase("LT");
    }

    public static void main(String[] args) {
        System.out.println(1&3);
    }
}
